/* Copyright (C) 2015, Heifai Information Technology Co., Ltd. All rights reserved. */
var app = angular.module("fd", []);
app.factory("commonService", ["$http", "$location", function(a, b) {
    var c = {};
    return c.randomOne = function(a) {
        var b = Math.floor(Math.random() * a.length);
        return a[b]
    }, c.getUrlParams = function(a, b, c) {
        var d = a.split("?"),
            e = "";
        if (d[1]) {
            var f = d[1].split("&");
            if (f && f.length > 0)
                for (var g = 0; g < f.length; g++) {
                    var h = f[g].split("=");
                    h[0] == b && (e = h[1])
                }
        }
        return ("function" == typeof c || c instanceof Function) && c(e), e
    }, c.formatToHHmmss = function(a, b) {
        var c = parseInt(a),
            d = 0,
            e = 0;
        c > 60 && (d = parseInt(c / 60), c = parseInt(c % 60), d > 60 && (e = parseInt(d / 60), d = parseInt(d % 60)));
        var f = "" + parseInt(c) < 9 ? "0" + parseInt(c) : parseInt(c);
        return d > 0 && (f = "00" == f ? "" + parseInt(d) < 9 ? "0" + parseInt(d) : parseInt(d) : "" + parseInt(d) < 9 ? "0" + parseInt(d) : parseInt(d) + ":" + f), e > 0 && (f = "" + parseInt(e) + ":" + f), ("function" == typeof b || b instanceof Function) && b(f), f
    }, c.formatToNumber = function(a, b) {
        var c = a.split(":"),
            d = 0;
        return c && c.length > 0 && (2 == c.length ? d = 3600 * c[0] + 60 * c[1] : 3 == c.length && (d = 3600 * c[0] + 60 * c[1] + 1 * c[2])), ("function" == typeof b || b instanceof Function) && b(d), d
    }, c.formatToNumberFromDate = function(a, b) {
        var c = 0;
        return c += 3600 * a.getHours(), c += 60 * a.getMinutes(), c += a.getSeconds()
    }, c.getAuthentication = function(a, c) {
        var d = {
                all: ["/", "/login", "/register", "/restaurants", "/restaurant", "/philosophy", "/profile", "/public-number", "/public-verifyEmail"],
                guest: [],
                customer: ["/checkout", "/orders", "/orders-unfinished"],
                restaurantUser: ["/restaurant-orders", "/restaurant-dishes", "/restaurant-restaurant", "/restaurant-orders-unfinished", "/restaurant-orders-unreceived"],
                regionalManager: ["/regional-orders", "/regional-region", "/regional-restaurants", "/regional-orders-unreceived", "/regional-orders-unfinished"],
                administrator: ["/platform-users", "/platform-users-customer", "/platform-users-restaurantUser", "/platform-users-regionalManager", "/platform-users-administrator", "/platform-user", "/platform-user-add", "/platform-userOrders", "/platform-userOrders-unreceived", "/platform-userOrders-unfinished", "/platform-restaurants", "/platform-restaurant", "/platform-restaurant-add", "/platform-restaurantDishes", "/platform-restaurantDish", "/platform-restaurantDish-add", "/platform-restaurantOrders", "/platform-restaurantOrders-unreceived", "/platform-restaurantOrders-unfinished", "/platform-regions", "/platform-region", "/platform-region-add", "/platform-regionalOrders-unfinished", "/platform-regionalOrders-unreceived"]
            },
            e = b.absUrl().lastIndexOf("/"),
            f = b.absUrl().substring(e, b.absUrl().length),
            g = f.replace("#", "").split("?");
        if (b.absUrl().indexOf("/restaurants") > 0) c(a && void 0 != a && "" != a ? "success" : "loginFailure");
        else if (a && void 0 != a && "" != a) {
            for (var h = d.all, i = !1, j = 0; j < h.length; j++) h[j] == g[0] && (i = !0);
            if (i) c("success");
            else {
                for (var k = d[a], l = !1, m = 0; m < k.length; m++) k[m] == g[0] && (l = !0);
                c(l ? "success" : "limit")
            }
        } else {
            for (var h = d.all, i = !1, j = 0; j < h.length; j++) h[j] == g[0] && (i = !0);
            c(i ? "notOperate" : "loginFailure")
        }
    }, c
}]), app.factory("apiService", ["$http", function(a) {
    var b = {};
    return b.initialized = !1, b.api = void 0, b.refresh = function(c) {
        a.get("/api").success(function(a, d, e, f) {
            b.api = a.api, b.initialized = !0, c()
        }).error(function(a, d, e, f) {
            b.api = void 0, b.initialized = !1, c()
        })
    }, b.init = function(a) {
        b.initialized ? a() : b.refresh(a)
    }, b.getApi = function(a) {
        b.init(function() {
            a(b.api)
        })
    }, b
}]), app.factory("loginService", ["$http", "apiService", function(a, b) {
    var c = {};
    return c.initialized = !1, c.loginInfo = void 0, c.refresh = function(d) {
        b.getApi(function(b) {
            a({
                method: "GET",
                url: b + "/login",
                withCredentials: !0
            }).success(function(a, b, e, f) {
                a && a.id ? c.loginInfo = a : c.loginInfo = void 0, c.initialized = !0, d()
            }).error(function(a, b, e, f) {
                c.loginInfo = void 0, c.initialized = !1, d()
            })
        })
    }, c.init = function(a) {
        c.initialized ? a() : c.refresh(a)
    }, c.getLogin = function(a) {
        c.init(function() {
            a(c.loginInfo)
        })
    }, c.postLogin = function(d, e, f) {
        b.getApi(function(b) {
            a({
                method: "POST",
                url: b + "/login",
                data: {
                    userIdentifier: d,
                    password: e
                },
                withCredentials: !0
            }).success(function(a, b, d, e) {
                c.refresh(function() {
                    c.getLogin(f)
                })
            }).error(function(a, b, d, e) {
                c.refresh(function() {
                    c.getLogin(f)
                })
            })
        })
    }, c.deleteLogin = function(d) {
        b.getApi(function(b) {
            a({
                method: "DELETE",
                url: b + "/login",
                withCredentials: !0
            }).success(function(a, b, e, f) {
                c.refresh(function() {
                    c.getLogin(d)
                })
            }).error(function(a, b, e, f) {
                c.refresh(function() {
                    c.getLogin(d)
                })
            })
        })
    }, c
}]), app.factory("infoService", ["$http", "apiService", function(a, b) {
    var c = {};
    return c.getRules = function(c) {
        b.getApi(function(b) {
            a({
                method: "GET",
                url: b + "/info/rules",
                withCredentials: !0
            }).success(function(a, b, d, e) {
                c("number" == typeof a.deliveryPrice || a.deliveryPrice instanceof Number ? a : void 0)
            }).error(function(a, b, d, e) {
                c(void 0)
            })
        })
    }, c.getServerTime = function(c) {
        b.getApi(function(b) {
            a({
                method: "GET",
                url: b + "/info/time",
                withCredentials: !0
            }).success(function(a, b, d, e) {
                c("number" == typeof a.timeNumber || a.timeNumber instanceof Number ? a : void 0)
            }).error(function(a, b, d, e) {
                c(void 0)
            })
        })
    }, c.getRestaurantCode = function(c) {
        b.getApi(function(b) {
            a({
                method: "GET",
                url: b + "/info/restaurants",
                withCredentials: !0
            }).success(function(a, b, d, e) {
                c(a && null != a ? a : void 0)
            }).error(function(a, b, d, e) {
                c(void 0)
            })
        })
    }, c
}]), app.factory("infoRestaurantsService", ["$http", "apiService", function(a, b) {
    var c = {};
    return c.getInfo = function(c) {
        b.getApi(function(b) {
            a({
                method: "GET",
                url: b + "/info/restaurants",
                withCredentials: !0
            }).success(function(a, b, d, e) {
                c(a && null != a ? a : void 0)
            }).error(function(a, b, d, e) {
                c(void 0)
            })
        })
    }, c
}]), app.factory("utilsMapService", ["$http", "apiService", function(a, b) {
    var c = {};
    return c.getAddressAvailable = function(c, d) {
        b.getApi(function(b) {
            a({
                method: "GET",
                url: b + "/utils/map/address/available?address=" + c,
                withCredentials: !0
            }).success(function(a, b, c, e) {
                d(a)
            }).error(function(a, b, c, e) {
                d({
                    available: !1,
                    precise: !1
                })
            })
        })
    }, c.getAddressSuggestion = function(c, d) {
        b.getApi(function(b) {
            a({
                method: "GET",
                url: b + "/utils/map/address/suggestion?query=" + c,
                withCredentials: !0
            }).success(function(a, b, c, e) {
                d(a)
            }).error(function(a, b, c, e) {
                d([])
            })
        })
    }, c.getShipping = function(c, d, e) {
        b.getApi(function(b) {
            a({
                method: "GET",
                url: b + "/utils/map/shipping?origin=" + c + "&destination=" + d,
                withCredentials: !0
            }).success(function(a, b, c, d) {
                e(a)
            }).error(function(a, b, c, d) {
                e({
                    origin: {
                        available: !1,
                        precise: !1
                    },
                    destination: {
                        available: !1,
                        precise: !1
                    }
                })
            })
        })
    }, c
}]), app.factory("restaurantsService", ["$http", "apiService", function(a, b) {
    var c = {};
    return c.getRestaurants = function(c) {
        b.getApi(function(b) {
            a({
                method: "GET",
                url: b + "/restaurants",
                withCredentials: !0
            }).success(function(a, b, d, e) {
                c(a && ("array" == typeof a || a instanceof Array) ? a : void 0)
            }).error(function(a, b, d, e) {
                c(void 0)
            })
        })
    }, c.getRestaurantsById = function(c, d) {
        b.getApi(function(b) {
            a({
                method: "GET",
                url: b + "/restaurants/" + c,
                withCredentials: !0
            }).success(function(a, b, c, e) {
                d(a ? a : void 0)
            }).error(function(a, b, c, e) {
                d(void 0)
            })
        })
    }, c.getRestaurantByCode = function(c, d) {
        b.getApi(function(b) {
            a({
                method: "GET",
                url: b + "/restaurants?code=" + c,
                withCredentials: !0
            }).success(function(a, b, c, e) {
                d(a ? a : void 0)
            }).error(function(a, b, c, e) {
                d(void 0)
            })
        })
    }, c.postRestaurants = function(c, d) {
        b.getApi(function(b) {
            a({
                method: "POST",
                url: b + "/restaurants",
                data: c,
                withCredentials: !0
            }).success(function(a, b, c, e) {
                d(!0)
            }).error(function(a, b, c, e) {
                d(!1)
            })
        })
    }, c.putRestaurants = function(c, d) {
        b.getApi(function(b) {
            a({
                method: "PUT",
                url: b + "/restaurants/" + c.id,
                data: c,
                withCredentials: !0
            }).success(function(a, b, c, e) {
                d(!0)
            }).error(function(a, b, c, e) {
                d(!1)
            })
        })
    }, c.deleteRestaurants = function(c, d) {
        b.getApi(function(b) {
            a({
                method: "DELETE",
                url: b + "/restaurants/" + c,
                withCredentials: !0
            }).success(function(a, b, c, e) {
                d(!0)
            }).error(function(a, b, c, e) {
                d(!1)
            })
        })
    }, c.putRestaurantActive = function(c, d, e) {
        b.getApi(function(b) {
            a({
                method: "PUT",
                url: b + "/restaurants/" + c + "/active",
                data: {
                    active: d
                },
                withCredentials: !0
            }).success(function(a, b, c, d) {
                e(a ? !0 : !1)
            }).error(function(a, b, c, d) {
                e(!1)
            })
        })
    }, c
}]), app.factory("registerService", ["$http", "apiService", function(a, b) {
    var c = {};
    return c.getCaptchaApi = function(a) {
        b.getApi(function(b) {
            void 0 != b && (b += "/register/captcha"), a(b)
        })
    }, c.getCaptcha = function(c) {
        b.getApi(function(b) {
            a({
                method: "GET",
                url: b + "/register/captcha",
                withCredentials: !0
            }).success(function(a, b, d, e) {
                c(a ? a : void 0)
            }).error(function(a, b, d, e) {
                c(void 0)
            })
        })
    }, c.postRegister = function(c, d, e, f) {
        b.getApi(function(b) {
            a({
                method: "POST",
                url: b + "/register?captcha=" + e,
                data: {
                    username: null,
                    email: {
                        value: null
                    },
                    name: c,
                    address: "",
                    phone: {
                        value: c
                    },
                    password: d
                },
                withCredentials: !0
            }).success(function(a, b, c, d) {
                f(!0)
            }).error(function(a, b, c, d) {
                f(!1)
            })
        })
    }, c.getAvailable = function(c, d) {
        b.getApi(function(b) {
            a({
                method: "GET",
                url: b + "/register/available?userIdentifier=" + c,
                withCredentials: !0
            }).success(function(a, b, c, e) {
                d(a && a.available ? !0 : !1)
            }).error(function(a, b, c, e) {
                d(void 0)
            })
        })
    }, c
}]), app.factory("usersService", ["$http", "apiService", function(a, b) {
    var c = {};
    return c.getUsers = function(c, d) {
        b.getApi(function(b) {
            a({
                method: "GET",
                url: b + "/users/" + c,
                withCredentials: !0
            }).success(function(a, b, c, e) {
                d(a ? a : void 0)
            }).error(function(a, b, c, e) {
                d(void 0)
            })
        })
    }, c.getUserByIdentifier = function(c, d) {
        b.getApi(function(b) {
            a({
                method: "GET",
                url: b + "/users?userIdentifier=" + c,
                withCredentials: !0
            }).success(function(a, b, c, e) {
                d(a ? a : void 0)
            }).error(function(a, b, c, e) {
                d(void 0)
            })
        })
    }, c.getCountUsersByRole = function(c, d) {
        b.getApi(function(b) {
            a({
                method: "GET",
                url: b + "/countUsers?role=" + c,
                withCredentials: !0
            }).success(function(a, b, c, e) {
                d(a ? a : void 0)
            }).error(function(a, b, c, e) {
                d(void 0)
            })
        })
    }, c.getUsersByRole = function(c, d, e, f) {
        b.getApi(function(b) {
            a({
                method: "GET",
                url: b + "/users?role=" + c + "&offset=" + d + "&limit=" + e,
                withCredentials: !0
            }).success(function(a, b, c, d) {
                f(a ? a : void 0)
            }).error(function(a, b, c, d) {
                f(void 0)
            })
        })
    }, c.postUsers = function(c, d, e, f, g, h, i, j, k) {
        var l = {};
        l = "customer" == e ? {
            username: c,
            password: d,
            role: e,
            name: f,
            email: {
                value: g
            },
            phone: {
                value: h
            },
            address: i
        } : "restaurantUser" == e ? {
            username: c,
            password: d,
            role: e,
            name: f,
            email: {
                value: g
            },
            phone: {
                value: h
            },
            restaurantId: j
        } : {
            username: c,
            password: d,
            role: e,
            name: f,
            email: {
                value: g
            },
            phone: {
                value: h
            }
        }, b.getApi(function(b) {
            a({
                method: "POST",
                url: b + "/users",
                data: l,
                withCredentials: !0
            }).success(function(a, b, c, d) {
                k(!0)
            }).error(function(a, b, c, d) {
                k(!1)
            })
        })
    }, c.putUsers = function(c, d, e, f, g, h, i, j) {
        var k = {};
        e && "" != e && void 0 != e && (k.username = e), f && "" != f && void 0 != f ? k.email = {
            value: f
        } : k.email = void 0, g && "" != g && void 0 != g && (k.password = g), "customer" == d ? (k.name = h, k.address = i) : k.name = h, b.getApi(function(b) {
            a({
                method: "PUT",
                url: b + "/users/" + c,
                data: k,
                withCredentials: !0
            }).success(function(a, b, c, d) {
                j(!0)
            }).error(function(a, b, c, d) {
                j(!1)
            })
        })
    }, c.deleteUsers = function(c, d) {
        b.getApi(function(b) {
            a({
                method: "DELETE",
                url: b + "/users/" + c,
                withCredentials: !0
            }).success(function(a, b, c, e) {
                d(!0)
            }).error(function(a, b, c, e) {
                d(!1)
            })
        })
    }, c.putUserActive = function(c, d, e) {
        b.getApi(function(b) {
            a({
                method: "PUT",
                url: b + "/users/" + c + "/active",
                data: {
                    active: d
                },
                withCredentials: !0
            }).success(function(a, b, c, f) {
                e(a && a.active == d ? !0 : !1)
            }).error(function(a, b, c, d) {
                e(!1)
            })
        })
    }, c.putUserEmailVerification = function(c, d, e) {
        b.getApi(function(b) {
            a({
                method: "PUT",
                url: b + "/users/" + c + "/email/verification",
                data: {
                    verified: d
                },
                withCredentials: !0
            }).success(function(a, b, c, f) {
                e(a && a.verified == d ? !0 : !1)
            }).error(function(a, b, c, d) {
                e(!1)
            })
        })
    }, c.postUserEmailVerifier = function(c, d, e) {
        b.getApi(function(b) {
            a({
                method: "POST",
                url: b + "/users/" + c + "/email/verifier",
                data: {
                    email: d
                },
                withCredentials: !0
            }).success(function(a, b, c, d) {
                e(a && 1 == a.success ? !0 : !1)
            }).error(function(a, b, c, d) {
                e(!1)
            })
        })
    }, c.putUserEmailVerifier = function(c, d, e) {
        b.getApi(function(b) {
            a({
                method: "PUT",
                url: b + "/users/" + c + "/email/verifier",
                data: {
                    verification_key: d
                },
                withCredentials: !0
            }).success(function(a, b, c, d) {
                e(a && 1 == a.success ? !0 : !1)
            }).error(function(a, b, c, d) {
                e(!1)
            })
        })
    }, c.putUserPhoneVerification = function(c, d, e) {
        b.getApi(function(b) {
            a({
                method: "PUT",
                url: b + "/users/" + c + "/phone/verification",
                data: {
                    verified: d
                },
                withCredentials: !0
            }).success(function(a, b, c, f) {
                e(a && a.verified == d ? !0 : !1)
            }).error(function(a, b, c, d) {
                e(!1)
            })
        })
    }, c
}]), app.factory("userCartService", ["$http", "apiService", function(a, b) {
    var c = {};
    return c.cart = {
        restaurantId: void 0,
        dishes: [],
        count: 0
    }, c.getUserCart = function(c, d) {
        b.getApi(function(b) {
            a({
                method: "GET",
                url: b + "/users/" + c + "/cart",
                withCredentials: !0
            }).success(function(a, b, c, e) {
                d(a ? a : void 0)
            }).error(function(a, b, c, e) {
                d(void 0)
            })
        })
    }, c.postUserCart = function(c, d, e) {
        b.getApi(function(b) {
            a({
                method: "POST",
                url: b + "/users/" + c + "/cart",
                data: {
                    dishId: d
                },
                withCredentials: !0
            }).success(function(a, b, c, d) {
                e(!0)
            }).error(function(a, b, c, d) {
                e(!1)
            })
        })
    }, c.putUserCart = function(c, d, e, f) {
        b.getApi(function(b) {
            a({
                method: "PUT",
                url: b + "/users/" + c + "/cart/" + d,
                data: {
                    quantity: e
                },
                withCredentials: !0
            }).success(function(a, b, c, d) {
                f(!0)
            }).error(function(a, b, c, d) {
                f(!1)
            })
        })
    }, c.deleteUserCart = function(c, d, e) {
        b.getApi(function(b) {
            a({
                method: "DELETE",
                url: b + "/users/" + c + "/cart/" + d,
                withCredentials: !0
            }).success(function(a, b, c, d) {
                e(!0)
            }).error(function(a, b, c, d) {
                e(!1)
            })
        })
    }, c
}]), app.factory("userOrdersService", ["$http", "apiService", function(a, b) {
    var c = {};
    return c.getUserOrder = function(c, d, e) {
        b.getApi(function(b) {
            a({
                method: "GET",
                url: b + "/users/" + c + "/orders/" + d,
                withCredentials: !0
            }).success(function(a, b, c, d) {
                e(a ? a : void 0)
            }).error(function(a, b, c, d) {
                e(void 0)
            })
        })
    }, c.getUserOrdersById = function(c, d) {
        b.getApi(function(b) {
            a({
                method: "GET",
                url: b + "/users/" + c + "/orders",
                withCredentials: !0
            }).success(function(a, b, c, e) {
                d(a ? a : void 0)
            }).error(function(a, b, c, e) {
                d(void 0)
            })
        })
    }, c.getUserOrders = function(c, d, e, f) {
        b.getApi(function(b) {
            a({
                method: "GET",
                url: b + "/users/" + c + "/orders?offset=" + d + "&limit=" + e,
                withCredentials: !0
            }).success(function(a, b, c, d) {
                f(a ? a : void 0)
            }).error(function(a, b, c, d) {
                f(void 0)
            })
        })
    }, c.getCountOrdersByStatus = function(c, d, e) {
        b.getApi(function(b) {
            a({
                method: "GET",
                url: b + "/users/" + c + "/countOrders?status=" + d,
                withCredentials: !0
            }).success(function(a, b, c, d) {
                e(a ? a : void 0)
            }).error(function(a, b, c, d) {
                e(void 0)
            })
        })
    }, c.getUserOrdersByStatus = function(c, d, e, f, g) {
        b.getApi(function(b) {
            a({
                method: "GET",
                url: b + "/users/" + c + "/orders?status=" + d + "&offset=" + e + "&limit=" + f,
                withCredentials: !0
            }).success(function(a, b, c, d) {
                g(a ? a : void 0)
            }).error(function(a, b, c, d) {
                g(void 0)
            })
        })
    }, c.postUserOrders = function(c, d, e) {
        b.getApi(function(b) {
            a({
                method: "POST",
                url: b + "/users/" + c + "/orders",
                data: d,
                withCredentials: !0
            }).success(function(a, b, c, d) {
                e(a)
            }).error(function(a, b, c, d) {
                e(void 0)
            })
        })
    }, c.deleteUserOrders = function(c, d, e) {
        b.getApi(function(b) {
            a({
                method: "DELETE",
                url: b + "/users/" + c + "/orders/" + d,
                withCredentials: !0
            }).success(function(a, b, c, d) {
                e(!0)
            }).error(function(a, b, c, d) {
                e(!1)
            })
        })
    }, c.putUserOrderStatus = function(c, d, e, f) {
        b.getApi(function(b) {
            a({
                method: "PUT",
                url: b + "/users/" + c + "/orders/" + d + "/status",
                data: {
                    status: e
                },
                withCredentials: !0
            }).success(function(a, b, c, d) {
                f(a ? !0 : !1)
            }).error(function(a, b, c, d) {
                f(!1)
            })
        })
    }, c
}]), app.factory("userOrderPaymentRequestService", ["$http", "apiService", function(a, b) {
    var c = {};
    return c.getPaymentRequest = function(c, d, e) {
        b.getApi(function(b) {
            a({
                method: "GET",
                url: b + "/users/" + c + "/orders/" + d + "/paymentRequest",
                withCredentials: !0
            }).success(function(a, b, c, d) {
                e(a ? a : void 0)
            }).error(function(a, b, c, d) {
                e(void 0)
            })
        })
    }, c
}]), app.factory("userRegionService", ["$http", "apiService", function(a, b) {
    var c = {};
    return c.getUserRegion = function(c, d) {
        b.getApi(function(b) {
            a({
                method: "GET",
                url: b + "/users/" + c + "/region",
                withCredentials: !0
            }).success(function(a, b, c, e) {
                d(a ? a : void 0)
            }).error(function(a, b, c, e) {
                d(void 0)
            })
        })
    }, c.postUserRegion = function(c, d, e) {
        b.getApi(function(b) {
            a({
                method: "POST",
                url: b + "/users/" + c + "/region",
                data: {
                    restaurantId: d
                },
                withCredentials: !0
            }).success(function(a, b, c, d) {
                e(!0)
            }).error(function(a, b, c, d) {
                e(!1)
            })
        })
    }, c.deleteUserRegion = function(c, d, e) {
        b.getApi(function(b) {
            a({
                method: "DELETE",
                url: b + "/users/" + c + "/region/" + d,
                withCredentials: !0
            }).success(function(a, b, c, d) {
                e(!0)
            }).error(function(a, b, c, d) {
                e(!1)
            })
        })
    }, c
}]), app.factory("restaurantDishesService", ["$http", "apiService", function(a, b) {
    var c = {};
    return c.getRestaurantDishes = function(c, d) {
        b.getApi(function(b) {
            a({
                method: "GET",
                url: b + "/restaurants/" + c + "/dishes",
                withCredentials: !0
            }).success(function(a, b, c, e) {
                d(a && ("array" == typeof a || a instanceof Array) ? a : void 0)
            }).error(function(a, b, c, e) {
                d(void 0)
            })
        })
    }, c.getRestaurantDishesById = function(c, d, e) {
        b.getApi(function(b) {
            a({
                method: "GET",
                url: b + "/restaurants/" + c + "/dishes/" + d,
                withCredentials: !0
            }).success(function(a, b, c, d) {
                e(a ? a : void 0)
            }).error(function(a, b, c, d) {
                e(void 0)
            })
        })
    }, c.postRestaurantDishes = function(c, d, e, f, g, h) {
        b.getApi(function(b) {
            a({
                method: "POST",
                url: b + "/restaurants/" + c + "/dishes",
                data: {
                    name: d,
                    introduction: e,
                    price: f,
                    thumbnail: g
                },
                withCredentials: !0
            }).success(function(a, b, c, d) {
                h(!0)
            }).error(function(a, b, c, d) {
                h(!1)
            })
        })
    }, c.putRestaurantDishes = function(c, d, e, f, g, h, i) {
        b.getApi(function(b) {
            a({
                method: "PUT",
                url: b + "/restaurants/" + c + "/dishes/" + d,
                data: {
                    name: e,
                    introduction: f,
                    price: g,
                    thumbnail: h
                },
                withCredentials: !0
            }).success(function(a, b, c, d) {
                i(!0)
            }).error(function(a, b, c, d) {
                i(!1)
            })
        })
    }, c.deleteRestaurantDishes = function(c, d, e) {
        b.getApi(function(b) {
            a({
                method: "DELETE",
                url: b + "/restaurants/" + c + "/dishes/" + d,
                withCredentials: !0
            }).success(function(a, b, c, d) {
                e(!0)
            }).error(function(a, b, c, d) {
                e(!1)
            })
        })
    }, c.putRestaurantDishAvailable = function(c, d, e, f) {
        b.getApi(function(b) {
            a({
                method: "PUT",
                url: b + "/restaurants/" + c + "/dishes/" + d + "/available",
                data: {
                    available: e
                },
                withCredentials: !0
            }).success(function(a, b, c, d) {
                f(a && a.available == e ? !0 : !1)
            }).error(function(a, b, c, d) {
                f(!1)
            })
        })
    }, c
}]), app.factory("restaurantOrdersService", ["$http", "apiService", function(a, b) {
    var c = {};
    return c.getRestaurantOrdersById = function(c, d, e) {
        b.getApi(function(b) {
            a({
                method: "GET",
                url: b + "/restaurants/" + c + "/orders/" + d,
                withCredentials: !0
            }).success(function(a, b, c, d) {
                e(a ? a : void 0)
            }).error(function(a, b, c, d) {
                e(void 0)
            })
        })
    }, c.getCountRestaurantOrdersByStatus = function(c, d, e) {
        b.getApi(function(b) {
            a({
                method: "GET",
                url: b + "/restaurants/" + c + "/countOrders?status=" + d,
                withCredentials: !0
            }).success(function(a, b, c, d) {
                e(a ? a : void 0)
            }).error(function(a, b, c, d) {
                e(void 0)
            })
        })
    }, c.getRestaurantOrdersByStatus = function(c, d, e, f, g) {
        b.getApi(function(b) {
            a({
                method: "GET",
                url: b + "/restaurants/" + c + "/orders?status=" + d + "&offset=" + e + "&limit=" + f,
                withCredentials: !0
            }).success(function(a, b, c, d) {
                g(a ? a : void 0)
            }).error(function(a, b, c, d) {
                g(void 0)
            })
        })
    }, c.getRestaurantOrders = function(c, d, e, f) {
        b.getApi(function(b) {
            a({
                method: "GET",
                url: b + "/restaurants/" + c + "/orders?offset=" + d + "&limit=" + e,
                withCredentials: !0
            }).success(function(a, b, c, d) {
                f(a ? a : void 0)
            }).error(function(a, b, c, d) {
                f(void 0)
            })
        })
    }, c.deleteRestaurantOrders = function(c, d, e) {
        b.getApi(function(b) {
            a({
                method: "DELETE",
                url: b + "/restaurants/" + c + "/orders/" + d,
                withCredentials: !0
            }).success(function(a, b, c, d) {
                e(!0)
            }).error(function(a, b, c, d) {
                e(!1)
            })
        })
    }, c.putRestaurantOrderStatus = function(c, d, e, f) {
        b.getApi(function(b) {
            a({
                method: "PUT",
                url: b + "/restaurants/" + c + "/orders/" + d + "/status",
                data: {
                    status: e
                },
                withCredentials: !0
            }).success(function(a, b, c, d) {
                f(a ? !0 : !1)
            }).error(function(a, b, c, d) {
                f("error")
            })
        })
    }, c.putRestaurantOrderDeliverer = function(c, d, e, f) {
        b.getApi(function(b) {
            a({
                method: "PUT",
                url: b + "/restaurants/" + c + "/orders/" + d + "/deliverer",
                data: {
                    deliverer: e
                },
                withCredentials: !0
            }).success(function(a, b, c, d) {
                f(a ? !0 : !1)
            }).error(function(a, b, c, d) {
                f(!1)
            })
        })
    }, c
}]), app.factory("autoLoginService", ["loginService", function(a) {
    var b = {},
        c = "74762385-78DD-6805-EE97-AC98D01D5D7D";
    return b.saveToCookie = function(a, b, d) {
        var e = new Base64,
            a = e.encode(a),
            b = e.encode(b),
            f = new Date,
            g = 2592e5;
        f.setTime(f.getTime() + g);
        var h = c + "=" + a + "|" + b + "; expires=" + f.toGMTString();
        document.cookie = h, d(!0)
    }, b.removeFromCookie = function(a) {
        var b = new Date;
        b.setTime(b.getTime() - 1), document.cookie = c + "=null; expires=" + b.toGMTString(), a(!0)
    }, b.login = function(b) {
        var d, e = new RegExp("(^| )" + c + "=([^;]*)(;|$)");
        if (d = document.cookie.match(e)) {
            var f = d[2],
                g = f.split("|");
            if (2 == g.length) {
                var h = new Base64;
                a.postLogin(h.decode(g[0]), h.decode(g[1]), function(a) {
                    b(a)
                })
            } else b(void 0)
        } else b(void 0)
    }, b
}]), app.factory("authenticateService", ["loginService", "autoLoginService", "commonService", function(a, b, c) {
    var d = {};
    return d.authenticate = function(d) {
        a.getLogin(function(a) {
            a && void 0 != a ? c.getAuthentication(a.role, function(a) {
                d(a)
            }) : b.login(function(a) {
                a && void 0 != a ? c.getAuthentication(a.role, function(a) {
                    d(a)
                }) : c.getAuthentication("", function(a) {
                    d(a)
                })
            })
        })
    }, d
}]), app.factory("findOpenOrderService", ["$window", "loginService", "userRegionService", "restaurantOrdersService", function(a, b, c, d) {
    var e = {},
        f = a.document.title;
    return e.findOpenOrder = function() {
        b.getLogin(function(a) {
            a && void 0 != a && ("restaurantUser" == a.role ? e.findRestaurantOpenOrder(a.restaurantId, function(a) {
                e.changeTitle(a)
            }) : "regionalManager" == a.role && e.findRegionalOpenOrder(a.id))
        })
    }, e.findRestaurantOpenOrder = function(a, b) {
        var c = "open";
        d.getCountRestaurantOrdersByStatus(a, c, function(a) {
            b(a && void 0 != a && a.count > 0 ? !0 : !1)
        })
    }, e.findRegionalOpenOrder = function(a) {
        c.getUserRegion(a, function(a) {
            if (a && void 0 != a)
                for (var b = 0; b < a.length; b++) {
                    var c = a[b];
                    e.findRestaurantOpenOrder(c, function(a) {
                        a && e.changeTitle(a)
                    })
                }
        })
    }, e.changeTitle = function(b) {
        b ? a.document.title = "【有新订单】" + f : a.document.title = f
    }, e.changeTitleForRegion = function(b) {
        b && a.document.title.indexOf("【有新订单】") < 0 && ($document.title = a.document.title + "【有新订单】")
    }, e
}]), $(function() {
    $(window).scroll(function() {
        $(window).scrollTop() > 100 ? $(".d-scroll-top-box").show() : $(".d-scroll-top-box").hide()
    }), $(".d-scroll-top-button").click(function() {
        $("body,html").animate({
            scrollTop: 0
        }, 600)
    }), $(".d-scroll-top-box").click(function() {
        $("body,html").animate({
            scrollTop: 0
        }, 600)
    }), $(".d-popover-text").popover({
        trigger: "hover",
        html: !1
    }), $(".d-popover-html").popover({
        trigger: "hover",
        html: !0
    })
}), app.controller("headerCtrl", ["$scope", "$window", "$location", "loginService", "userCartService", "autoLoginService", "findOpenOrderService", function(a, b, c, d, e, f, g) {
    function h() {
        var b = c.url().split("/");
        i(b[1], function(b) {
            a.modeTitle = b
        })
    }

    function i(a, b) {
        "kitchen" == a ? b("起筷厨房") : "cookbox" == a ? b("厨师魔盒") : "restaurants" == a && b("品牌餐厅")
    }
    a.cartCount = 0, (c.absUrl().indexOf("/restaurants#") || c.absUrl().indexOf("/restaurant#")) && h(), d.getLogin(function(b) {
        a.loginInfo = b, void 0 != a.loginInfo && void 0 != a.loginInfo.id && "customer" === a.loginInfo.role && e.getUserCart(a.loginInfo.id, function(b) {
            void 0 != b && void 0 != b.dishes && (e.cart.dishes = [], $.each(b.dishes, function(b, c) {
                a.cartCount += c.quantity, e.cart.dishes.push({
                    dishId: c.dishId,
                    quantity: c.quantity
                })
            }), e.cart.count = a.cartCount, e.cart.restaurantId = b.restaurantId)
        })
    }), a.logout = function() {
        f.removeFromCookie(function(a) {}), d.deleteLogin(function(c) {
            a.loginInfo = c, b.location.href = "/"
        })
    }, a.$on("titleChange", function(b, d) {
        var e = c.url().split("/");
        i(e[1], function(b) {
            a.modeTitle = b, a.$$phase || a.$apply()
        })
    }), a.$on("cartChange", function(b, c) {
        a.cartCount = e.cart.count, a.$$phase || a.$apply()
    })
}]), app.controller("platformHeaderCtrl", ["$scope", "$window", "$location", "loginService", "userCartService", "autoLoginService", "findOpenOrderService", function(a, b, c, d, e, f, g) {
    function h() {
        var b = c.absUrl();
        i(b, function(b) {
            a.subnavTitle = b
        })
    }

    function i(a, b) {
        a.indexOf("?") > -1 && (a = a.substring(0, a.indexOf("?"))), a.indexOf("#") > -1 && (a = a.substring(0, a.indexOf("#")));
        var c = a.substring(a.lastIndexOf("/") + 1, a.length);
        b(j[c])
    }
    var j = {
        "platform-users-customer": "所有顾客",
        "platform-users-restaurantUser": "所有餐厅用户",
        "platform-users-regionalManager": "所有区域经理",
        "platform-users-administrator": "所有管理员",
        "platform-user": "用户信息",
        "platform-user-add": "新增用户",
        "platform-userOrders": "顾客订单",
        "platform-userOrders-unreceived": "顾客未接收订单",
        "platform-userOrders-unfinished": "顾客未完成订单",
        "platform-restaurants": "所有餐厅",
        "platform-restaurant": "餐厅信息",
        "platform-restaurant-add": "新增餐厅",
        "platform-restaurantDishes": "所有菜式",
        "platform-restaurantDish": "菜式信息",
        "platform-restaurantDish-add": "新增菜式",
        "platform-restaurantOrders": "餐厅订单",
        "platform-restaurantOrders-unreceived": "餐厅未接收订单",
        "platform-restaurantOrders-unfinished": "餐厅未完成订单",
        "platform-regions": "所有区域",
        "platform-region": "区域管辖餐厅",
        "platform-region-add": "添加餐厅",
        "platform-regionalOrders-unreceived": "区域未接收订单",
        "platform-regionalOrders-unfinished": "区域未完成订单",
        "restaurant-restaurant": "我的餐厅",
        "restaurant-dishes": "餐厅菜式",
        "restaurant-orders": "餐厅订单",
        "restaurant-orders-unreceived": "餐厅未接收订单",
        "restaurant-orders-unfinished": "餐厅未完成订单",
        "regional-region": "管辖餐厅",
        "regional-orders": "区域餐厅订单",
        "regional-orders-unreceived": "区域未接收订单",
        "regional-orders-unfinished": "区域未完成订单"
    };
    h(), d.getLogin(function(b) {
        a.loginInfo = b
    }), setInterval(function() {
        a.$apply(h)
    }, 1e4), a.logout = function() {
        f.removeFromCookie(function(a) {}), d.deleteLogin(function(c) {
            a.loginInfo = c, b.location.href = "/"
        })
    }, $(".navbar-app").on("show.bs.collapse", function() {
        a.$root.$broadcast("HideSubMenu")
    }), a.navbarMore = function() {
        var b = $(".navbar-app");
        b.collapse("hide"), a.$root.$broadcast("ShowSubMenu")
    }
}]), app.controller("loginModalCtrl", ["$scope", "$window", "$location", "loginService", "autoLoginService", "autoLoginService", function(a, b, c, d, e) {
    a.rememberMe = !1, a.rememberMeClick = function() {
        a.rememberMe = !a.rememberMe
    }, a.submit = function() {
        e.removeFromCookie(function(a) {}), d.postLogin(a.loginUserIdentifier, a.loginPassword, function(b) {
            b ? (a.rememberMe && e.saveToCookie(a.loginUserIdentifier, a.loginPassword, function(a) {}), $(".login-modal").modal("hide"), location.reload()) : (a.loginUserIdentifier = "", a.loginPassword = "")
        })
    }
}]), app.filter("secondCase", function() {
    return function(a) {
        var b = parseInt(a),
            c = 0,
            d = 0;
        b > 60 && (c = parseInt(b / 60), b = parseInt(b % 60), c > 60 && (d = parseInt(c / 60), c = parseInt(c % 60)));
        var e = "" + parseInt(b) < 9 ? "0" + parseInt(b) : parseInt(b);
        return c > 0 && (e = "00" == e ? "" + parseInt(c) < 9 ? "0" + parseInt(c) : parseInt(c) : "" + parseInt(c) < 9 ? "0" + parseInt(c) : parseInt(c) + ":" + e), d > 0 && (e = "" + parseInt(d) + ":" + e), e
    }
}), app.filter("stateCase", function() {
    return function(a) {
        return a ? "已激活" : "未激活"
    }
}), app.filter("statusCase", function() {
    return function(a) {
        switch (a) {
            case "unpaid":
                return "未付款";
            case "open":
                return "已下单";
            case "received":
                return "已接收";
            case "cooking":
                return "烹饪中";
            case "delivering":
                return "配送中";
            case "finished":
                return "已完成";
            case "closed":
                return "已关闭"
        }
    }
}), app.filter("roleCase", function() {
    return function(a) {
        switch (a) {
            case "customer":
                return "顾客";
            case "restaurantUser":
                return "餐厅用户";
            case "regionalManager":
                return "区域经理";
            case "administrator":
                return "管理员"
        }
    }
}), app.directive("useridentifierCheck", ["registerService", function(a) {
    return {
        require: "ngModel",
        link: function(b, c, d, e) {
            b.$watch(d.ngModel, function() {
                void 0 == b.index && (b.index = 0), b.index++;
                var d = c.val();
                if (d && d.length > 0) {
                    var f = b.index;
                    a.getAvailable(c.val(), function(a) {
                        b.index == f && e.$setValidity("available", a)
                    })
                } else e.$setValidity("available", !0)
            })
        }
    }
}]), app.directive("pwCheck", [function() {
    return {
        require: "ngModel",
        link: function(a, b, c, d) {
            var e = "#" + c.pwCheck;
            b.add(e).on("keyup", function() {
                a.$apply(function() {
                    var a = b.val() === $(e).val();
                    d.$setValidity("pwmatch", a)
                })
            })
        }
    }
}]);